/*const snore: string = "Snore";
const breath: string = "Breath";
const speech: string = "Speech";
const move: string = "Move";
const cough: string = "Cough";
const bird: string = "Bird";
const dog: string = "Dog";
const cat: string = "Cat";
const grindTeeth: string = "Grind Teeth";
const cryingBaby: string = "Crying Baby";
const carHorn: string = "Car Horn";
const catathrenia: string = "Catathrenia";
const sniffle: string = "Sniffle";
const sneeze: string = "Sneeze";
const apnea: string = "Apnea";*/

type SoundType =
  | 'snore' | 'breath' | 'speech' | 'move'
  | 'cough' | 'bird' | 'dog' | 'cat'
  | 'grind_teeth' | 'crying_baby' | 'car_horn'
  | 'catathrenia' | 'sniffle' | 'sneeze' | 'apnea';

export class SoundMapper {
  private _idToName: Record<number, SoundType> | null = null;

  get idToName(): Record<number, SoundType> {
    if (!this._idToName) {
      this._idToName = {
        36: 'snore', //鼾声
        2: 'breath', //呼吸
        37: 'speech', //梦话
        27: 'move', //翻身
        9: 'cough', //咳嗽
        1: 'bird', //鸟叫
        14: 'dog', //狗叫
        6: 'cat', //猫叫
        22: 'grind_teeth', //磨牙
        13: 'crying_baby', //婴儿哭
        5: 'car_horn', //汽车
        41: 'catathrenia', //哼唧
        42: 'sniffle', //鼻塞
        19: 'sneeze', //打喷嚏
        99: 'apnea' //呼吸暂停
      };
    }
    return this._idToName;
  }

  private _nameToId: Record<SoundType, number> | null = null;

  get nameToId(): Record<SoundType, number> {
    if (!this._nameToId) {
      this._nameToId = Object.entries(this.idToName).reduce(
        (acc, [id, name]) => ({ ...acc, [name]: Number(id) }),
        {} as Record<SoundType, number>
      );
    }
    return this._nameToId;
  }

  getByNumer(id: number): SoundType | undefined {
    return this.idToName[id];
  }

  getByString(name: string): number | undefined {
    return this.nameToId.hasOwnProperty(name)
      ? this.nameToId[name as SoundType]
      : undefined;
  }

  isSoundType(input: string): input is SoundType {
    return this.nameToId.hasOwnProperty(input);
  }
}

/*
  static NSString * const snoreStr       = @"snore";        //鼾声
  static NSString * const speechStr      = @"speech";       //梦话
  static NSString * const breathStr      = @"breath";       //呼吸
  static NSString * const moveStr        = @"move";         //翻身
  static NSString * const coughStr       = @"cough";        //咳嗽
  static NSString * const birdStr        = @"bird";         //鸟叫
  static NSString * const dogStr         = @"dog";          //狗叫
  static NSString * const catStr         = @"cat";          //猫叫
  static NSString * const grind_teethStr = @"grind_teeth";  //磨牙
  static NSString * const crying_babyStr = @"crying_baby";  //婴儿哭
  static NSString * const otherStr       = @"other";        //其他
  static NSString * const unusualSnoreStr= @"unusual_snore";//异常鼾声
  static NSString * const carHornStr     = @"car_horn";     //汽车
  static NSString * const catathreniStr  = @"catathrenia";  //夜间呻吟：哼唧
  static NSString * const sniffleStr     = @"sniffle";      //抽鼻子：鼻塞
  static NSString * const apneaStr       = @"apnea";        //呼吸暂停
  static NSString * const sneezeStr      = @"sneeze";       //打喷嚏
*/
/*

export class SoundMapper {
  private _trainIds: Record<number, string> | null = null;

  get trainIds(): Record<number, string> {
    if (!this._trainIds) {
      this._trainIds = {
        36: snore,
        2: breath,
        37: speech,
        27: move,
        9: cough,
        1: bird,
        14: dog,
        6: cat,
        22: 'grind_teeth',
        13: 'crying_baby',
        5: 'car_horn',
        41: catathrenia,
        42: sniffle,
        19: sneeze,
        100000: apnea
      };
    }
    return this._trainIds;
  }
}*/


